# Maintainer: Felix Yan <felixonmars@archlinux.org>

_hkgname=hxt-regex-xmlschema
pkgname=haskell-hxt-regex-xmlschema 
pkgver=9.2.0.7
pkgrel=5
pkgdesc="A regular expression library for W3C XML Schema regular expressions"
url="https://www.haskell.org/haskellwiki/Regular_expressions_for_XML_Schema"
license=('MIT')
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-hxt-charproperties')
makedepends=('ghc')
source=("https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz")
sha512sums=('8ce1b2c1bcc79f8072d5b1dcfc9d184bb3286065b290e4df80fd02d454725d97d4346554a913a167eb97a45fba43b5000a08e8a9cf1dac129ff261b917d2e4cf')

build() {
    cd $_hkgname-$pkgver
    
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm \
            -f-profile
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd $_hkgname-$pkgver
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
